<#assign className=table.className>
<#assign classNameLower=className?uncap_first>
<#assign hasColumn="com.auto.ftl.FtlHasColumnMethod"?new()>
package ${basepackage}.controller.${bizPackage};


import com.cjy.common.utils.PreconditionsUtils;
import com.cjy.entity.${bizPackage}.${className}Entity;
import com.cjy.service.${bizPackage}.${className}Service;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.ApiImplicitParam;
import com.cjy.common.message.BaseResult;
import com.cjy.common.message.AjaxResult;
import com.cjy.common.message.ResultPage;
import ${basepackage}.vo.${bizPackage}.${className}Vo;
import com.cjy.common.message.IdsParamVo;
import java.util.List;


/**
 * 功能：${bizName}${table.sqlName}的Api
 *
 * @author ${authorName}
 * @version 1.0
 * @Date ${now?string('yyyy年MM月dd日 HH:mm:ss')}
 */
@RestController
@Api(tags = "${bizName}API")
public class ${className}Controller{

        private Logger logger=LoggerFactory.getLogger(getClass());

        @Autowired
        private ${className}Service ${classNameLower}Service;



        @ApiOperation(value = "获取${bizName}", notes = "根据主键id，获取${bizName}详情")
        @PostMapping(value = "/${controllerReqPre}/admin/${bizPackage}/${classNameLower}/id")
        public AjaxResult<${className}Entity> getByIdDetails(@RequestBody IdsParamVo vo){
                PreconditionsUtils.checkNotNull(vo.getId(),"id不能为空");
                ${className}Entity dbObj = ${classNameLower}Service.getByIdDetails(vo.getId());
                return AjaxResult.success("获取成功",dbObj);
        }


@ApiOperation(value = "查询${bizName}的列表")
        @PostMapping(value = "/${controllerReqPre}/admin/${bizPackage}/${classNameLower}/list")
        public ResultPage<List<${className}Entity>> list(@RequestBody ${className}Vo vo){
                return BaseResult.packPageResult(${classNameLower}Service.pageList(vo));
        }



        @ApiOperation(value = "保存或更新${bizName}")
        @PostMapping(value = "/${controllerReqPre}/admin/${bizPackage}/${classNameLower}/saveOrUpdate")
        public AjaxResult<${className}Entity> saveOrUpdate(@RequestBody ${className}Entity  pageObj){
                ${className}Entity dbObj = ${classNameLower}Service.saveOrUpdateDo(pageObj);
                return AjaxResult.success("保存成功",dbObj);
        }




        @ApiOperation(value = "删除${bizName}", notes = "根据主键id，删除${bizName}")
        @PostMapping(value = "/${controllerReqPre}/admin/${bizPackage}/${classNameLower}/remove")
        public AjaxResult remove(@RequestBody IdsParamVo vo){
                PreconditionsUtils.checkNotNull(vo.getIds(),"ids不能为空");
        <#if hasColumn(table.columns,"removed")>
                        //逻辑删除
                        ${classNameLower}Service.deleteLogicBatchById(vo.getIds());
        <#else>
                //物理删除
                ${classNameLower}Service.removeBatchByIds(CollUtil.toList(vo.getIds()));
        </#if>
                return AjaxResult.success("删除成功");
        }



        @ApiOperation(value = "获取${bizName}", notes = "根据主键id，获取${bizName}")
        @PostMapping(value = "/${controllerReqPre}/admin/${bizPackage}/${classNameLower}/listByIds")
        public AjaxResult<List<${className}Entity>> listByIds(@RequestBody IdsParamVo vo){
                PreconditionsUtils.checkNotNull(vo.getIds(),"ids不能为空");
                List<${className}Entity> list = ${classNameLower}Service.getListByIds(vo.getIds());
                return AjaxResult.success("获取成功",list);
        }

}
